public class t45 {
    public static void main(String[] args) {
        int arr[] = {2,3,1,1,4};
        int n = arr.length;
        /*if(n == 1){
            return 1;
        }*/
        int dp [] = new int [n];
        dp[0] = 0;
        for(int i =1;i<n;i++){
            dp[i] = Integer.MAX_VALUE;
            for(int j = 0;j<i;j++){
                if(i-j<=arr[j] && dp[j]!=Integer.MAX_VALUE){
                    dp[i] = Math.min(dp[i],dp[j]+1);
                    break;
                }
            }
        }
        //return dp[n-1];
        System.out.println(dp[n-1]);
    }
}
